package com.example.stream.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;

@Component
@Slf4j
public class MessageListener {

    @Value("${server.port}")
    private String serverPort;

    @Bean
    public Consumer<String> receiveMail() {
        return str -> {
            log.info("Port: {}, Receive Mail, Message: {}", serverPort, str);
        };
    }

    @Bean
    public Consumer<String> receiveMsg() {
        return str -> {
            log.info("Port: {}, Receive msg, Message: {}", serverPort, str);
        };
    }
}
